<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="kulstats.*" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%


UserManager userManager = Registry.userManager();
User currentUser = userManager.getCurrentUser();
if(currentUser != null) {
	//response.sendRedirect("/home");
}
UserService userService = UserServiceFactory.getUserService();
com.google.appengine.api.users.User aeUser = userService.getCurrentUser();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html> 
<head> 
	<title>Register - StAPP</title> 
	
	<%@ include file="mobileResources.inc.jsp" %>
	
</head>

<body>
<div data-role="page" id="registerPage">
	<div data-role="header">
		<center><div id="StAPPimageDiv">
		<img src="images/StAPP_header_logo.png" id="StAPPimage" width="400px" height="60px">
		</div>
		<h3 id="StAPPheaderText">Student Application For Personal Progress</h3>
		</center>
		<br/><br/>
	</div><!-- /header -->
	<div data-role="content">
		<h3>Register on StAPP</h3>
		<form action="DoRegister" method="post" id="reg_form" data-ajax="false">
		
<%!
public ArrayList<Course> CourseListWrapper(String richting, String fase) {
CourseManager courseManager = Registry.courseManager();
ArrayList<Course> allCourses = courseManager.getAllCourses();
ArrayList<Course> displayCourses = new ArrayList<Course>();
for(Course course : allCourses) {
	if(course.getCourseID().startsWith(richting)){ 
		if(course.getCourseID().contains(fase)){
			displayCourses.add(course);		 
			}
		}
	}
return displayCourses;
}

String richting1 = "";
String fase1="";
int i =0;
%>
			<div data-role="fieldcontain" >
				<label for="reg_name">Your name:</label>
				<input type="text" name="reg_name" id="reg_name" value="<%=aeUser.getNickname() %>" />
			</div>
			<div data-role="fieldcontain">
				<label >E-mail:</label>
				<span id="reg_mail"><%=aeUser.getEmail() %></span>
			</div>
			
			<div data-role="fieldcontain">
			<center>	<div data-role="content" style="display: block;" id="richtingselect_div" class="selectdiv">
	                <select name="reg_studyList" value="Studierichting" id="richtingselect">
		                <option selected="selected">Select your study:</option>
		                <option name="bir" value="bir0">Burgerlijk Ingenieur</option>
		                <option name="bira" value="bira">Burgerlijk Ingenieur Architect</option>
	                </select>
                </div></center>
              
              <center> <div data-role="content" style="display: none;" id="faseselect_div" class="selectdiv">
	                <select name="reg_faseList" value="Studiefase" id="faseselect">
		                <option selected="selected">Select your fase:</option>
		                <option name="bach_1" value="bach1">1ste Bachelor</option>
		                <option name="bach_2" value="bach2">2de Bachelor</option>
		                <option name="bach_3" value="bach3">3de Bachelor</option>
		                <option name="mas_1" value="mas1">1ste Master</option>
		                <option name="mas_2" value="mas2">2de Master</option>
	                </select>
                </div></center> 
              <div data-role="content" id="info">
              <div data-role="content" id="infoDiv" style="display: none;"></div>
              <div data-role="content" id="changeHoofdNeven" style="display: none;" class="minormajordiv_2">
              <button name="nieuwHoofdNeven" id="changeButton" value="Change">Change</button>
              </div>
              </div>
                <div data-role="content" style="display: none;" id="head_radiodiv" class="minormajordiv">
                		<p> Select your major:</p>
		                <input type="radio" name="hoofdrichting" id="bwk" value="Bouwkunde" />
		                <label for="bwk">Bouwkunde</label>
		                <input type="radio" name="hoofdrichting" id="cit" value="Chemische Technologie" />
		                <label for="cit">Chemische Technologie</label>
		                <input type="radio" name="hoofdrichting" id="comp_wet" value="Computerwetenschappen" />
		                <label for="comp_wet">Computerwetenschappen</label>
		                <input type="radio" name="hoofdrichting" id="esat" value="Elektrotechniek" />
		                <label for="esat">Elektrotechniek</label>
		                <input type="radio" name="hoofdrichting" id="geo" value="Geotechniek en mijnbouwkunde" />
		                <label for="geo">Geotechniek en mijnbouwkunde</label>
		                <input type="radio" name="hoofdrichting" id="mat" value="Materiaalkunde" />
		                <label for="mat">Materiaalkunde</label>
		                <input type="radio" name="hoofdrichting" id="werk" value="Werktuigkunde" />
		                <label for="werk">Werktuigkunde</label>
                </div>
                <div data-role="content" style="display: none;" id="aside_radiodiv" class="minormajordiv">
                		<p> Select your minor:</p>
		                <input type="radio" name="nevenrichting" id="bwk_n" value="Bouwkunde" />
		                <label for="bwk_n">Bouwkunde</label>
		                <input type="radio" name="nevenrichting" id="cit_n" value="Chemische Technologie" />
		                <label for="cit_n">Chemische Technologie</label>
		                <input type="radio" name="nevenrichting" id="comp_wet_n" value="Computerwetenschappen" />
		                <label for="comp_wet_n">Computerwetenschappen</label>
		                <input type="radio" name="nevenrichting" id="esat_n" value="Elektrotechniek" />
		                <label for="esat_n">Elektrotechniek</label>
		                <input type="radio" name="nevenrichting" id="geo_n" value="Geotechniek en mijnbouwkunde" />
		                <label for="geo_n">Geotechniek en mijnbouwkunde</label>
		                <input type="radio" name="nevenrichting" id="mat_n" value="Materiaalkunde" />
		                <label for="mat_n">Materiaalkunde</label>
		                <input type="radio" name="nevenrichting" id="werk_n" value="Werktuigkunde" />
		                <label for="werk_n">Werktuigkunde</label>
                </div>
              
              
              
              <div data-role="content" id="courseListWrapper_bir0_1b" style="display: none;" class="minormajordiv">
				<p>Select your courses: </p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="bir0";
fase1="1b";
ArrayList<Course> displayCourses1 = CourseListWrapper(richting1,fase1);
i=1;
for(Course course : displayCourses1) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="1eBachGem"/>
					<label for="reg_course_<%=i %>"><%=course.getName() %></label>		
<%
			i++;
	}
%>
				</fieldset>
			</div>
                <div data-role="content" id="courseListWrapper_bir0_2b" style="display: none;" class="minormajordiv">
				<p>Select your courses: </p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="bir0";
fase1="2b";
ArrayList<Course> displayCourses2 = CourseListWrapper(richting1,fase1);
i=1;
for(Course course : displayCourses2) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="2eBachGem" />
					<label for="reg_course_<%=i%>"><%=course.getName() %></label>		
<%
			i++;
		}
%>
				</fieldset>
			</div>
			
			    <div data-role="content" id="courseListWrapper_bircw_2b" style="display: none;" class="minormajordiv">
			    <p> Major courses:</p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="bircw";
fase1="2b";
ArrayList<Course> displayCourses3 = CourseListWrapper(richting1,fase1);
int k=1;
for(Course course : displayCourses3) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="2eBachCW"/>
					<label for="reg_course_<%=i %>"><%=course.getName() %></label>		
<%
			i++;
	}
%>
				</fieldset>
			</div>
			
			 <div data-role="content" id="courseListWrapper_bircit_2b" style="display: none;" class="minormajordiv">
				<p>CIT courses:</p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="bircit";
fase1="2b";
ArrayList<Course> displayCourses4 = CourseListWrapper(richting1,fase1);
int i=1;
for(Course course : displayCourses4) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="2eBachCIT"/>
					<label for="reg_course_<%=i %>"><%=course.getName() %></label>		
<%
			i++;
	}
%>
				</fieldset>
			</div>	
			<div data-role="content" id="courseListWrapper_birbwk_2b" style="display: none;" class="minormajordiv">
				<p>BWK courses:</p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="birbwk";
fase1="2b";
ArrayList<Course> displayCourses5 = CourseListWrapper(richting1,fase1);
i=1;
for(Course course : displayCourses5) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="2eBachBWK"/>
					<label for="reg_course_<%=i %>"><%=course.getName() %></label>		
<%
			i++;
	}
%>
				</fieldset>
			</div>	
			<div data-role="content" id="courseListWrapper_biresat_2b" style="display: none;" class="minormajordiv">
				<p>ESAT courses:</p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="biresat";
fase1="2b";
ArrayList<Course> displayCourses6 = CourseListWrapper(richting1,fase1);
i=1;
for(Course course : displayCourses6) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="2eBachESAT"/>
					<label for="reg_course_<%=i %>"><%=course.getName() %></label>		
<%
			i++;
	}
%>
				</fieldset>
			</div>
						<div data-role="content" id="courseListWrapper_birgeo_2b" style="display: none;" class="minormajordiv">
				<p>GEO courses:</p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="birgeo";
fase1="2b";
ArrayList<Course> displayCourses7 = CourseListWrapper(richting1,fase1);
i=1;
for(Course course : displayCourses7) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="2eBachGEO"/>
					<label for="reg_course_<%=i %>"><%=course.getName() %></label>		
<%
			i++;
	}
%>
				</fieldset>
			</div>
						<div data-role="content" id="courseListWrapper_birmat_2b" style="display: none;" class="minormajordiv">
				<p>MAT courses:</p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="birmat";
fase1="2b";
ArrayList<Course> displayCourses8 = CourseListWrapper(richting1,fase1);
i=1;
for(Course course : displayCourses8) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="2eBachMAT"/>
					<label for="reg_course_<%=i %>"><%=course.getName() %></label>		
<%
			i++;
	}
%>
				</fieldset>
			</div>
						<div data-role="content" id="courseListWrapper_birwerk_2b" style="display: none;" class="minormajordiv">
				<p>WERK courses:</p>
				<fieldset data-role="controlgroup" id="courseList">
<%
richting1="birwerk";
fase1="2b";
ArrayList<Course> displayCourses9 = CourseListWrapper(richting1,fase1);
i=1;
for(Course course : displayCourses9) {
%>
					<input type="checkbox" name="reg_courses" id="reg_course_<%=i %>" value="<%=course.getCourseID() %>" class="2eBachWERK"/>
					<label for="reg_course_<%=i %>"><%=course.getName() %></label>		
<%
			i++;
	}
%>
				</fieldset>
			</div>
			</div>
			
			<div data-role="fieldcontain" class="checker" id="checkerDiv" style="display: none;">
				<input type="button" name="selectAll" id="selectAllButton" value="Select All" />
				<input type="button" name="deselectAll" id="deselectAllButton" value="Deselect All" />
			</div>
			<div data-role="fieldcontain">
				<input type="submit" name="submit" id="submit" value="Register" />
			</div>
		</form>	
	</div><!-- /content -->
	<div data-role="footer">
		<h4>&copy; 2011 - StAPP</h4>
	</div><!-- /footer -->
</div><!-- /page -->


</body>
</html>